//  Copyright (c) 2008  Yoong-ki Ahn & Youngjin Kim < mexif@googlegroups.com>
//  See the enclosed file COPYING for license information (MIT Licence).
//  If you did not receive this file,
//  see http://www.opensource.org/licenses/mit-license.php.

package mexif;

public class JpegMarker {
	/* Start Of Frame N */
    final public int M_SOF0	= 0xC0;  

    /* N indicates which compression process */
    final public int M_SOF1	= 0xC1;  

    /* Only SOF0-SOF2 are now in common use */
    final public int M_SOF2	= 0xC2;  
    final public int M_SOF3  = 0xC3;

    /* NB: codes C4 and CC are NOT SOF markers */
    final public int M_SOF5	= 0xC5;  
    final public int M_SOF6	= 0xC6;
    final public int M_SOF7	= 0xC7;
	final public int M_JPG	= 0xC8;
    final public int M_SOF9	= 0xC9;
    final public int M_SOF10	= 0xCA;
    final public int M_SOF11	 = 0xCB;
    final public int M_SOF13	= 0xCD;
    final public int M_SOF14	= 0xCE;
    final public int M_SOF15	= 0xCF;

    final public int M_DHT	= 0xC4;	// define huffman table(s)
    final public int M_DAC	= 0xCC;  // define arithmentic coding conditions

    final public int M_RST0	= 0xD0;
    final public int M_RST1	= 0xD1;
    final public int M_RST2	= 0xD2;
    final public int M_RST3	= 0xD3;
    final public int M_RST4	= 0xD4;
    final public int M_RST5	= 0xD5;
    final public int M_RST6	= 0xD6;
    final public int M_RST7	= 0xD7;
    
    /* Start Of Image (beginning of datastream) */
    final public int M_SOI   = 0xD8;	

    /* End Of Image (end of datastream) */
    final public int M_EOI   = 0xD9;	

    /* Start Of Scan (begins compressed data) */
    final public int M_SOS   = 0xDA;	

    final public int M_DQT	= 0xdb;
	final public int M_DNL	= 0xdc;
	final public int M_DRI	= 0xdd;
	final public int M_DHP	= 0xde;
	final public int M_EXP	= 0xdf;
	
   
    /* Application-specific marker, type N */
    final public int M_APP0  = 0xE0;	
    final public int M_APP1  = 0xE1;
    final public int M_APP2  = 0xE2;
    final public int M_APP3  = 0xE3;
    final public int M_APP4  = 0xE4;
    final public int M_APP5  = 0xE5;
    final public int M_APP6  = 0xE6;
    final public int M_APP7  = 0xE7;
    final public int M_APP8  = 0xE8;
    final public int M_APP9  = 0xE9;
    final public int M_APP10 = 0xEA;
    final public int M_APP11 = 0xEB;
    final public int M_APP12 = 0xEC;	
    final public int M_APP13 = 0xED;
    final public int M_APP14 = 0xEE;
    final public int M_APP15 = 0xEF;

	final public int M_JFIF				= 0xe0;
	final public int M_EXIF				= 0xe1;
	
    final public int M_COMMENT   = 0xFE;
    final public int M_PseudoImage	= 0xff;
    
    /* The maximal comment length */
    final public int M_MAX_COM_LENGTH = 65500;
    
    String getMarkername(int marker) {
    	switch(marker) {
    	case M_SOF0:  		return new String("SOF0");
    	case M_SOF1:  		return new String("SOF1");
    	case M_SOF2:  		return new String("SOF2");
    	case M_SOF3:  		return new String("SOF3");
    	case M_SOF5:  		return new String("SOF5");
    	case M_SOF6:  		return new String("SOF6");
    	case M_SOF7:		return new String("SOF7");
    	case M_JPG:			return new String("JPG");
    	case M_SOF9:		return new String("SOF9");
    	case M_SOF10:		return new String("SOF10");
    	case M_SOF11:		return new String("SOF11");
    	case M_SOF13:		return new String("SOF13");
    	case M_SOF14:		return new String("SOF14");
    	case M_SOF15:		return new String("SOF15");
    	case M_DHT:			return new String("DHT");
    	case M_DAC:			return new String("DAC");
    	case M_RST0:		return new String("RST)");
        case M_RST1:		return new String("RST1");
        case M_RST2:		return new String("RST2");
        case M_RST3:		return new String("RST3");
        case M_RST4:		return new String("RST4");
        case M_RST5:		return new String("RST5");
        case M_RST6:		return new String("RST6");
        case M_RST7:		return new String("RST7");

        case M_SOI:			return new String("StartOfImage");
        case M_EOI:			return new String("EndOfImage");
        case M_SOS:			return new String("StartOfScan");

        case M_DQT:			return new String("DQT");
    	case M_DNL:			return new String("DNL");
    	case M_DRI:			return new String("DRI");
    	case M_DHP:			return new String("DHP");
    	case M_EXP:			return new String("EXP");
    	
        case M_APP0:		return new String("APP0");
        case M_APP1:		return new String("APP1");
        case M_APP2:		return new String("APP2");
        case M_APP3:		return new String("APP3");
        case M_APP4:		return new String("APP4");
        case M_APP5:		return new String("APP5");
        case M_APP6:		return new String("APP6");
        case M_APP7:		return new String("APP7");
        case M_APP8:		return new String("APP8");
        case M_APP9:		return new String("APP9");
        case M_APP10:		return new String("APP10");
        case M_APP11:		return new String("APP11");
        case M_APP12:		return new String("APP12");
        case M_APP13:		return new String("APP13");
        case M_APP14:		return new String("APP14");
        case M_APP15:		return new String("APP15");
        case M_COMMENT:		return new String("Comment");
    	default:
    		return null;
    	}
    }
}
